"""
@author: wy
@file: lianxi.py
@time: 2024/2/28 16:49
"""

class Role():
    blood = 100
    room_id = None

    def __init__(self,name,gender,equip):
        self.name = name
        self.gender = gender
        self.equip = equip


    def fighting(self,enemy,room):
        if self.room_id == enemy.room_id and room.room_members == room.max_players:
            while self.blood !=0  or enemy.blood  !=0:
                if self.equip != 0 and enemy.equip !=0:
                    self.blood -= 5
                    enemy.blood -= 5
                elif self.equip == 0 and enemy.equip !=0:
                    self.blood -= 10
                    enemy.blood -= 5
                elif self.equip != 0 and enemy.equip ==0:
                    self.blood -= 5
                    enemy.blood -= 10
                else:
                    self.blood -= 10
                    enemy.blood -= 10
                if self.blood == 0:
                    print(f"{enemy.name} victory")
                    break
                elif enemy.blood == 0:
                    print(f"{self.name} victory")
                    break


class Room():

    def __init__(self,room_id,room_members,max_players):
        self.room_id = room_id
        self.room_members = room_members
        self.max_players = max_players
        self.players = []

    def join_room(self, player):
        if len(self.players) < self.max_players:
            self.players.append(player)
            player.room_id = self.room_id
            self.room_members += 1
            print(f"{player.name} has joined Room {self.room_id}.")
        else:
            print("Room is full. Cannot join.")

user1 = Role("wang","man",1)
user2 = Role("li","woman",0)

room1 = Room(1,0,2)

room1.join_room(user1)
room1.join_room(user2)


user1.fighting(user2,room1)

